/**
 * Order entity.
 */
package models;

import java.util.ArrayList;
import java.util.List;

import javax.persistence.CascadeType;
import javax.persistence.Embedded;
import javax.persistence.Entity;
import javax.persistence.OneToMany;
import javax.persistence.Table;

import play.data.validation.Required;
import play.db.jpa.Model;

@Entity
@Table(name="user_order")
public class Order extends Model {

	@Embedded
	@Required
	public User user;
	
	@Required
	public DeliveryType deliveryType;
	
	public SalePoint salePoint;
	
	@OneToMany (mappedBy="userOrder", cascade = CascadeType.ALL)
	public List<OrderItem> items;
	
	public Order(User user, DeliveryType deliveryType, SalePoint salePoint) {
		this.user = user;
		this.deliveryType = deliveryType;
		this.salePoint = salePoint;
		this.items = new ArrayList<OrderItem>();
	}
}
